<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>${fns:getConfig('productName')}</title>
  <link rel="stylesheet" href="${ctxStatic}/layui-v2.5.6/layui/css/layui.css">
  <script type="text/javascript" src="${ctxStatic}/layui-v2.5.6/layui/layui.js"></script>

</head>

<body>

<div class="layui-fluid">
<div class="layui-card">
<div class="layui-form layui-card-header layuiadmin-card-header-auto" style="padding-top: 10px;padding-bottom: 10px;">
   
  <div class="layui-form-item">
  
  
 	<label class="layui-form-label">部门名称:</label>
		<div class="layui-input-inline" style="width: 160px;">
		     <input type="text" id="updateById" name="updateById" autocomplete="off" class="layui-input">
		</div> 
	 
	
	<label class="layui-form-label">起止日期：</label>
		<div class="layui-input-inline" style="width: 160px;">
		     <input type="text" id="fillInDate" name="fillInDate" autocomplete="off" class="layui-input">
		</div>
	<label class="layui-form-label" style="width: 10px;">至</label>
		<div class="layui-input-inline" style="width: 160px;">
		     <input type="text" id="approvalDate" name="approvalDate" autocomplete="off" class="layui-input"><!--审批时间  -->
		</div>
	
	
	<label class="layui-form-label">年份：</label>
		 <div class="layui-input-inline">
			<select name="year" id="year">
		      	 <option value="">请选择</option>
				<c:forEach items="${fns:getDictList('jx_projectPerformanceReport_year')}" var="year">
					<option value="${year.value}">${year.label}</option>
				</c:forEach>  
			 </select>
		</div> 
		<!-- <div class="layui-input-inline" style="width: 160px;">
		     <input type="text" id="approvalDate" name="year" autocomplete="off" class="layui-input">审批时间 
		</div> -->
     <button class="layui-btn layuiadmin-btn-comm" id="queryBtn" data-type="reload" lay-submit="" lay-filter="LAY-app-contcomm-search">
         <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
    </button> 
   
  </div>
  
</div>
<div class="layui-card-body">
	<table id="table" lay-filter="test" class="demo-tree-more"></table>
</div> 
</div>
</div>
<script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
	
    	<button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon layui-icon-add-1"></i>新增</button>
	
  </div>
</script>

<!-- 行工具栏 -->
<script type="text/html" id="barDemo">

      <a class="layui-btn layui-btn-xs layui-btn-normal btn-auth" lay-event="editt" ekper="web/disease/editDisease">修改</a>
	  <a class="layui-btn layui-btn-xs layui-btn-normal btn-auth" lay-event="edit" ekper="web/disease/editDisease">目标指示管理</a>
      <a class="layui-btn layui-btn-xs layui-btn-danger btn-auth" lay-event="del" ekper="web/disease/deleteDisease">删除</a>


</script>


<script>
layui.use(['table','form','laydate'], function(){
  var table = layui.table;
  var form = layui.form; 
  var $ = layui.$;
  var laydate = layui.laydate;
  
  var firstDate = new Date();
   firstDate.setDate(1); //第一天
  var endDate = new Date(firstDate);
  endDate.setMonth(firstDate.getMonth()+1);
  endDate.setDate(0);  
  
   
laydate.render({
			elem: '#fillInDate',
			trigger: 'click', //采用click弹出
			value: new Date(firstDate)
		});
		//日期
		laydate.render({
			elem: '#approvalDate',
			trigger: 'click', //采用click弹出
			value: new Date(endDate)
		}); 

  table.render({
	id: 'thisReloadId'
    ,elem: '#table'
    ,height: 650
    ,url:'${ctx}/jx/projectPerformanceReport/listByAjax'
     ,toolbar: '#toolbarDemo'  //开启头部工具栏，并为其绑定左侧模板
    ,defaultToolbar: ['filter', 'exports', 'print']//layui扩展图功能
     ,title: '绩效管理' 
    ,totalRow:true//开启合计行
    ,cols: [[
	
		{field:'expendName', title:'项目支出名称',width:200}
		,{field:'year', title:'年份',width:200}	
		,{field:'competentDepartment', title:'主管部门',width:200}
		,{field:'updateById', title:'部门名称',width:200, templet:'<div>{{d.office ? d.office.name : ""}}</div>'}	/* updateBy更新者 */
		,{field:'enforceUnit', title:'实施单位',width:200}	
		,{field:'totalDeginningYearBudget', title:'年度预算总额',width:200}
		,{field:'totalAnnualBudget', title:'年度预算总额全年初预算数',width:200}	
		,{field:'dnBeginningYearBudgetLayout', title:'当年预算安排一年初预算数',width:200}
		,{field:'dnAnnualBudgetLayout', title:'当年预算总额一全年预算数',width:150}	
		,{field:'snBeginningYearCarryoverFunds', title:'上年结转经费一年初预算数',width:200}
		,{field:'snAnnualCarryoverFunds', title:'上年结转经费一全年预算数',width:200}	
		,{field:'otherFundsBeginningYear', title:'其他来源经费一年初预算数',width:200}
		,{field:'otherFundsAnnual', title:'其他来源经费一全年初预算数',width:200}	
		,{field:'annualPerformanceGoal', title:'本年度绩效目标',width:200}
		 ,{field:'fillInName', title:'填报人',width:200}	
		,{field:'fillInDate', title:'填报日期',templet : "<div>{{d.fillInDate ? layui.util.toDateString(d.fillInDate, 'yyyy-MM-dd') : ''}}</div>",width:200}	
		,{field:'fillInPhone', title:'联系电话',width:200}	
		/* ,{field:'submitStatus', title:'提交状态',width:200} */	/*：0未提交  1已提交  */
		   ,{field:'status', title:'审批状态',width:200} 	 /*  ：0未审批 、1审批通过、2驳回*/
		/*  ,{field:'reply', title:'审批内容',width:200}	
		,{field:'approvalDate', title:'审批时间',templet : "<div>{{d.approvalDate ? layui.util.toDateString(d.approvalDate, 'yyyy-MM-dd') : ''}}</div>",width:200}	
		,{field:'createBy', title:'创建者',width:200}	
		,{field:'createDate', title:'创建时间',templet : "<div>{{d.createDate ? layui.util.toDateString(d.createDate, 'yyyy-MM-dd') : ''}}</div>",width:200}	
		 */
		/* ,{field:'updateDate', title:'更新时间',templet : "<div>{{d.updateDate ? layui.util.toDateString(d.updateDate, 'yyyy-MM-dd') : ''}}</div>",width:200}	  
		 ,{field:'remarks', title:'备注',width:200}	  */
		/*  ,{field:'delFlag', title:'删除',width:200}	
		  */
      ,{fixed: 'right', title:'操作', toolbar: '#barDemo',width:350}
    ]]
    ,page: false
    ,done: function (res, curr, count) {
    	$(".layui-table th").css({"font-family":"黑体","font-size":"15","font-weight":"bold"});// 设定表格标题字体加粗
    }
  });
	   $('#queryBtn').on('click', function(){
		  var year = $('#year').val();
	       var updateById = $('#updateById').val();   
	      /* alert("rent value:"+rent);   */
	      //执行重载
	      table.reload('thisReloadId', {
	    	method : 'post',
	        where: { //查询条件
	        	year:year
	        }
	      }); 
	         /*  alert("你好嘛! value:"+rent);    */
	  });  
	  
  //头工具栏事件
  table.on('toolbar(test)', function(obj){
    var checkStatus = table.checkStatus(obj.config.id);
    data = checkStatus.data; //获取选中的数据
    switch(obj.event){
      case 'add':
        layer.open({
        	id:'1',
    		type: 2,
    	    title: '增加资产',
    	    btn: ['关闭'],
    	    yes: function(index, layero){
    	    	layer.close(index);
    	    },
    	    shadeClose: true,
    	    shade: false,
    	    area: ['893px', '650px'],
    	    content: '${ctx}/jx/projectPerformanceReport/form'
    	});
      break;
    };
  });
  //监听行工具事件
  table.on('tool(test)', function(obj){
    var data = obj.data;
    if(obj.event === 'del'){
      layer.confirm('真的删除该行么？', function(index){
        $.ajax({
            url: "${ctx}/jx/projectPerformanceReport/deleteById",
            type: "POST",
            dataType: "json",
            data: {
            	id : data.id
            },
            async: false,
            success: function(data){
                layer.close(index);
                //执行重载
                table.reload('thisReloadId', {
                  page: {
                    curr: 1 //重新从第 1 页开始
                  }
                }, 'data');
                layer.msg(data);
            },
            error: function(){
            	layer.msg('删除失败', {icon: 2});
            }
        });
      });
    } 
    else if(obj.event === 'editt'){
    	//iframe窗
    	layer.open({
    		id:'3',
    		type: 2,
    	    title: '绩效考核',
    	    btn: ['关闭'],
    	    yes: function(index, layero){
    	    	layer.close(index);
    	    },
    	    shadeClose: true,
    	    shade: false,
    	    area: ['2100px', '920px'],
    	    content: '${ctx}/jx/projectPerformanceReport/form?id='+data.id
    	});
    }
    else if(obj.event === 'edit'){
    	//iframe窗
    	layer.open({
    		id:'3',
    		type: 2,
    	    title: '绩效考核',
    	    btn: ['关闭'],
    	    yes: function(index, layero){
    	    	layer.close(index);
    	    },
    	    shadeClose: true,
    	    shade: false,
    	    area: ['2100px', '920px'],
    	    content: '${ctx}/jx/projectAimTarget/list?id='+data.id
    	});
    }
  });
  function timestampToTime(timestamp) {
	    var date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
	    var Y = date.getFullYear() + '-';
	    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
	    var D = date.getDate();
	    return Y + M + D;
  }
});

</script>
</body>
</html>